package com.amtf.datafile2.core.txt;

import com.amtf.datafile2.DataException;
import com.amtf.datafile2.DataField;
import com.amtf.datafile2.DataFieldType;

public class TxtFTNumeric extends TxtFTBasic {

	public static final DataFieldType instance = new TxtFTNumeric("Numeric");

	public TxtFTNumeric(String name) {
		super(name);
	}

	public TxtFTNumeric(int minLength, int maxLength) {
		super(instance.getName(), minLength, maxLength);
	}

	public void validate(DataField value) throws DataException {
		super.validate(value);

		String tmpValue = (String) value.getValue();
		try {
			Double.parseDouble(tmpValue);
		} catch (Throwable e) {
			throw new DataException("Value type not match with definition:" + name);
		}
	}

}
